package cn.com.oidreams.aliyun.robot.entity;

import cn.com.oidreams.common.enums.ExceptionCode;
import lombok.Getter;

/**
 * @author 五六七
 * @description: 基类异常
 * @date 2020/7/30 16:42
 */
@Getter
public class BaseException extends RuntimeException{

    private int code= ExceptionCode.FAIL.getKey();
    private ExceptionCode errorCode;
    private String message;
    private  Object entity;
    public BaseException() {
        errorCode = ExceptionCode.SYSTEM_ERROR;
    }
    public BaseException(String message) { this.message = message; }
    public BaseException(String message, Throwable e) { super(message, e); }
    public BaseException(Throwable e) { super(e); }
    public BaseException(ExceptionCode exceptionCode){
        this.errorCode=exceptionCode;
    }
    public BaseException(ExceptionCode exceptionCode, Object entity) {
        super();
        errorCode = exceptionCode;
        this.entity=entity;
    }
    public BaseException(ExceptionCode exceptionCode, Throwable e) {
        super(e);
        errorCode = exceptionCode;
    }
    public BaseException(String message, ExceptionCode exceptionCode) {
        super(message);
        errorCode = exceptionCode;
        this.message = message;
    }
    public BaseException(String message, ExceptionCode exceptionCode, Throwable e) {
        super(message, e);
        errorCode = exceptionCode;
    }
    public ExceptionCode getErrorCode() {
        return errorCode;
    }
    public BaseException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }
}
